<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>佑晟电商-M系统登录</title>
	<link rel="stylesheet" type="text/css" href="<?php echo STATIC_URL;?>plugin/layui/css/layui.css" rel="stylesheet" />
	<link rel="stylesheet" href="<?php echo STATIC_URL;?>admin/yzm_admin/css/yzm.admin.login.css" />
	<link rel="Shortcut Icon" href="<?php echo STATIC_URL;?>admin/yzm_admin/images/favicon.ico" />
</head>
<body>
	<div class="yzm-loginwarrp">
		<div class="yzm-logo">管理员登录</div>
        <div class="yzm-login-form">
			<form method="post" action="" onsubmit="return dologin(this)">
			    <ul>
					<li class="yzm-login-item">
						<input type="text" name="username" class="yzm-login-input" autofocus="autofocus" placeholder="请输入用户名">
						<span>用户名：</span>
					</li>
					<li class="yzm-login-item">					
						<input type="password" name="password" class="yzm-login-input" placeholder="请输入密码">
						<span>密码：</span>
					</li>
					<li class="yzm-login-item code" <?php if(!isset($_SESSION['is_code'])){?>style="display:none;"<? } ?>>
						<img src="<?php echo U('api/index/code');?>" id="codeimg" class="yzm-verifyimg" onclick="this.src=this.src+'?'"/>
						<input type="text" name="code" class="yzm-login-input yzm-verify-input" placeholder="请输入验证码">
						<span>验证码：</span>
					</li>
					<li class="yzm-login-sub">
						<input type="submit" name="dosubmit" value="登　录" />
					</li>
					<li style="line-height:20px;text-align:right;margin-top:10px;"><a style="color:#333;text-decoration:none;" class="c-primary" href="<?php echo U('reg');?>">没有账号？点击注册</a></li>
			    </ul>	
           </form>
		</div>
	</div>
	<ul class="yzm-circles">
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
	</ul>
	<div class="yzm-footer"><p>©<?php echo date('Y');?> 广州佑晟电子商务有限公司</p></div>
	<script type="text/javascript" src="<?php echo STATIC_URL;?>plugin/jquery/1.8.2/jquery.min.js"></script> 
	<script type="text/javascript" src="<?php echo STATIC_URL;?>plugin/layui/layui.js"></script>
	<script type="text/javascript">
	layui.use(['layer'], function(){
		var layer = layui.layer;
	});
	function dologin(obj) {
		if(obj.username.value==''){
			layer.msg('请输入用户名！', {icon:2});
			return false;
		}
		if(obj.password.value==''){
			layer.msg('请输入密码！', {icon:2});
			return false;
		}
		if(obj.code.value=='' && $('.code').css('display')!='none'){
			layer.msg('请输入验证码！', {icon:2, time:1000});
			return false;
		}
		layer.msg('正在登录……', {icon:16, time:0, shade:0.3});
		$.ajax({
			type: 'POST',
			url: '<?php echo U('login');?>', 
			data: $(obj).serialize(),
			dataType: "json", 
			success: function (msg) {
				if(msg.status == 1){
					layer.msg(msg.message, {icon:1, time:1200}, function(){
						window.location.href = msg.url;
					});
				}else{
					$("#codeimg").attr('src',$("#codeimg").attr('src') + '?' + Math.random());
					$('.code').show();
					layer.msg(msg.message, {icon:2, time:2000}, function(){
						$(".yzm-verify-input").val('');
					});
				}
			}
		})		 
		return false;			
	}
	</script>
</body>
</html>